/*
 * =====================================================================================
 *
 *       Filename:  3637qsort.c
 *
 *    Description:  implement qsort
 *
 *        Version:  1.0
 *        Created:  2012年06月29日 15时38分33秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Regan (), lcqhigh@gmail.com
 *        Company:  
 *
 * =====================================================================================
 */

#include	<stdio.h>
#include	<stdlib.h>
#include	<math.h>

#define	T   short			/*  */

inline void swap(T *a, T *b) 
{
    T tmp = *a;
    *a = *b;
    *b = tmp;
}

//return the index of the pivot
int partion(T *x, int n)
{
    if (n < 2)
        return 0;
    int mid = abs(rand()) % n;
    int l, h;
    if (n > 2) {
        --n;        
        if (mid < 1 || mid > n-1)
            mid = 1;
        if (x[0] > x[mid]) swap(&x[0], &x[mid]);
        if (x[mid] > x[n]) swap(&x[mid], &x[n]);
        if (x[0] > x[mid])   swap(&x[0], &x[mid]);

        swap(&x[mid], &x[n-1]);
        l = 0;
        h = n - 1;
        for (;;) {
            while (x[++l] < x[n-1]);
            while (x[--h] > x[n-1]);
            if (l >= h)
                break;
            swap(&x[l], &x[h]);
        }
        swap(&x[l], &x[n-1]);
        return l;
    } else if (n == 2) {
        if (x[0] > x[1])        
            swap(&x[0], &x[1]);
        return 0;
    }
    return 0;
}

void insert_sort(T *x, int n)
{
    int idx = 0, k = 0;
    T tmp;
    for (idx = 1; idx < n; ++idx)
    {
        tmp = x[idx];
        for (k = idx; k > 0; --k) {
            if (tmp < x[k-1])
                x[k] = x[k-1];
            else
                break;
        }
        x[k] = tmp;
    }
}

void myqsort(T *x, int n)
{
    int pivot;
    if (n <= 9 && n > 1)
        insert_sort(x, n);
    else if (n > 1) {
        pivot = partion(x, n);
        myqsort(x, pivot);
        myqsort(x+pivot+1, n-pivot-1);
    }
    return;
}

int main()
{
    T prices[20000];
    int times, items_count;
    int idx = 0, off = 0;
    int total_discount = 0;
    scanf("%d", &times);
    while (times--)
    {
        scanf("%d", &items_count);
        for (idx = 0; idx < items_count; ++idx)
            scanf("%hd", &prices[idx]);
        myqsort(prices, items_count);
        //insert_sort(prices, items_count);
        total_discount = 0;
        off = items_count - 3;
        while (off >= 0)
        {
            total_discount += prices[off];
            off -= 3;
        }
        printf ( "%d\n", total_discount);
    }
    return 0;
}
